package j06date;

import java.text.SimpleDateFormat;
import java.util.Date;

public class J1 {
    public static void main(String[] args) {
        Date d1 = new Date();
        System.out.println("d1 = " + d1);
        //毫秒数  1724663362174  时间戳
        System.out.println(d1.getTime());

        Date d2 = new Date(0);
        System.out.println("d2 = " + d2);

        Date yesterday = new Date(d1.getTime()-24*3600*1000);
        System.out.println("yesterday = " + yesterday);

        System.out.println(d1.after(yesterday));//true

        System.out.println("====");
        Date now = new Date();
        System.out.println("now = " + now);
        now.setTime(0);
        System.out.println("now = " + now);
        System.out.println(now.toString());

    }
}
//2021-12-22 12:00:45
class J2{
    public static void main(String[] args) {
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM-dd H#m#s");
        String s1 = sdf.format(now);
        System.out.println("s1 = " + s1);
        try {
            Date d2 = sdf.parse(s1);
            System.out.println("d2 = " + d2);//乱
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}